home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEtransformRelated.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.1 KB  |  134 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // FILE: AEtransformRelated.mel
  18. // INPUT: string (node name)
  19. // RETURN:    string[] (list of related nodes, with the node whose
  20. //            tab you want to be opened duplicated at the
  21. //            end of the array)
  22. //
  23.  
  24.  
  25. global proc int AEisLastNodeDuplicated(string $inputArray[])
  26. {
  27.     int         $inputArraySizeMinusOne = size($inputArray)-1;
  28.     if ($inputArraySizeMinusOne < 1) return false;
  29.     string $searchString = $inputArray[$inputArraySizeMinusOne];
  30.     string $tmp[] = `ls -l $searchString`;
  31.     $searchString = $tmp[0];
  32.     for ($i = 0; $i < $inputArraySizeMinusOne; $i++) {
  33.         clear $tmp;
  34.         $tmp = `ls -l $inputArray[$i]`;
  35.         if ( $searchString == $tmp[0]) return true;
  36.     }
  37.     return false;
  38. }
  39.  
  40.  
  41. global proc string[] AEtransformRelated (string $nodeName)
  42. {
  43.     string $retval[];
  44.     string $preferredNode = "";
  45.  
  46.     // get all shapes immediately below the transform first
  47.     //
  48.     string $leaves[] = `listRelatives -fullPath -shapes $nodeName`;
  49.     for ($leaf in $leaves) {
  50.         $retval[size($retval)] = $leaf;
  51.     }
  52.  
  53.     // now get the connections for the transform
  54.     // to deal with things like expressions, motionPaths, etc.
  55.     //
  56.     string $tmp[];
  57.     $tmp = `defaultNavigation -ren -d $nodeName`;
  58.     for ($node in $tmp) {
  59.         $retval[size($retval)] = $node;
  60.     }
  61.  
  62.     // loop through each of the leaves looking for
  63.     // appropriate AE<leafType>Related.mel scripts
  64.     //
  65.     for ($leaf in $leaves) {
  66.  
  67.         clear $tmp;
  68.         // get the leaf's nodeType
  69.         string $leafType = `nodeType $leaf`;
  70.  
  71.         // build the related script's name
  72.         string $relatedScript = "AE"+$leafType+"Related";
  73.  
  74.         if (`exists $relatedScript`) {
  75.  
  76.             // if an AE*Related script exists for the shape leaf
  77.             // node, run it 
  78.             //
  79.             $tmp = eval($relatedScript+" \""+$leaf+"\"");
  80.  
  81.             // Check if the last item is duplicated.
  82.             // AEisLastNodeDuplicated is a Mel script which will
  83.             // search the input string array for a duplicate
  84.             // occurrence of the last element in that array.
  85.             // AEisLastNodeDuplicated returns 1 if true, 0 if false.
  86.             // (this script is shown below)
  87.             //
  88.             // Note that any node that has been designated "internal"
  89.             // is not a candidate for preferred status.
  90.             //
  91.             if (AEisLastNodeDuplicated($tmp) == true) {
  92.                 string $pNode = $tmp[size($tmp)-1];
  93.                 if ( !`attributeQuery -ex -node $pNode intermediateObject` ||
  94.                      !`getAttr ($pNode+".intermediateObject")` ){
  95.                     $preferredNode = $pNode;
  96.                 }
  97.             }
  98.  
  99.         } else {
  100.  
  101.             $tmp = `defaultNavigation -ren -d $leaf`;
  102.             string $tmpPreferredNode = `defaultNavigation -dwn -d $leaf`;
  103.             string $tmpPreferredFullPathName[] = `ls -l $tmpPreferredNode`;
  104.             if ( $tmpPreferredFullPathName[0] != $leaf 
  105.                 || $preferredNode == "" )
  106.             {
  107.                 $preferredNode = $tmpPreferredNode;
  108.                 $tmp[size($tmp)] = $preferredNode;
  109.             }
  110.  
  111.         }
  112.  
  113.         // catenate the result to the return string array ($retval)
  114.         for ($i = 0; $i < size($tmp); $i++) {
  115.             $retval[size($retval)] = $tmp[$i];
  116.         }
  117.  
  118.     }
  119.  
  120.     // Note that if you have multiple leaves and each specifies
  121.     // a preferredNode, only the last one is remembered.
  122.     // If no preferredNode was specified, the transform itself
  123.     // is used.
  124.     //
  125.     if ($preferredNode == "") {
  126.         $retval[size($retval)] = $nodeName;
  127.     } else {
  128.         $retval[size($retval)] = $preferredNode;
  129.     }
  130.     
  131.     return $retval;
  132. }
  133.  
  134.